import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class MenuDemo(QMainWindow):
    def __init__(self,parents=None):
        super(MenuDemo, self).__init__(parents)
        layout=QHBoxLayout()
        bar=self.menuBar()
        file=bar.addMenu('File')
        setting=bar.addMenu('Setting')
        file.addAction('New')
        save=QAction('Save',self)
        save.setShortcut('Ctrl+S')
        file.addAction(save)
        edit=file.addMenu('Edit')
        edit.addAction('copy')
        edit.addAction('paste')
        quit=QAction('Quit',self)
        file.addAction(quit)
        file.triggered[QAction].connect(self.processtrigger)
        self.setLayout(layout)
        self.setWindowTitle('MENU')

    def processtrigger(self,q):
        print(q.text())

if __name__ == '__main__':
    app=QApplication(sys.argv)
    demo=MenuDemo()
    demo.show()
    sys.exit(app.exec_())